﻿
@{
    ViewBag.Title = "新增下载模板";
}
@model KTD.Web.Models.VD.AdvCUD

<div class="x-body" id="saveResult" style="width:100%;">
    <div class="layui-form">
        @*@Html.HiddenFor(model => model.Id)*@
        @Html.HiddenFor(model => model.type)
        <div class="layui-form-item">
            <div class="layui-inline">
                <label for="L_email" class="layui-form-label">
                    <span class="x-red">*</span>标题
                </label>
                <div class="layui-input-inline">
                    @Html.TextBoxFor(model => model.advname, new { @class = "layui-input" })
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_email" class="layui-form-label">
                <span class="x-red">*</span>下载文件
            </label>
            <div class="layui-input-inline">
                <input type="file" id="file" class="layui-input" />
            </div>

        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label for="L_email" class="layui-form-label">
                    <span class="x-red">*</span>顺序
                </label>
                <div class="layui-input-inline">
                    @Html.TextBoxFor(model => model.displayorder, new { @class = "layui-input", @type = "number" })
                </div>
            </div>
        </div>
        @*<label for="L_email" class="layui-form-label">
            <span class="x-red">*</span>内容
        </label>
        <div class="layui-form-item">


            @Html.TextAreaFor(model => model.query, new { @class = "layui-input", style = "width:100%;height:200px;display:none;" })
            <div id="editor">
                <p>
                    @Html.Raw(HttpUtility.HtmlDecode(Model.query))
                </p>
            </div>
        </div>*@
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button id="btnAdd" class="layui-btn" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </div>
</div>



@section scripts{
    <script src="~/Scripts/wangEditor.min.js"></script>
    <script>
    
        layui.use(['form', 'layer'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;

       

            //监听提交
            form.on('submit(add)', function (data) {
                var formdata = new FormData();
                //formdata.append("Id", $("#Id").val());
                formdata.append("advname", $("#advname").val());
              formdata.append("displayorder", $("#displayorder").val());
                formdata.append("type", $("#type").val());
                formdata.append("file", $("#file")[0].files[0]);
                $.ajax({

                    url: "/Adv/CreateDownload",
                    type: "post",
                    data: formdata,
                    processData: false,    // 不处理数据
                    contentType: false,    // 不设置内容类型

                    success: function (data) {

                        //发异步，把数据提交给php
                        layer.alert("新增成功", { icon: 6 }, function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            parent.window.location.reload();
                        });
                    }
                })
                return false;
            });


        });

    </script>
}